package com.prs.um.usermanager.dto;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

import com.prs.um.deptmanager.dto.Dept;
import com.prs.um.dutymanager.dto.Duty;

@Table(name="SYSTEM_USER")
@Entity
public class User implements Serializable{
	
	
	private static final long serialVersionUID = 1L;
	
	@Id
	@Column(name = "ID_",length=36)
	@GenericGenerator(name="uuid",strategy="uuid")
	@GeneratedValue(generator="uuid")
	private String id;
	
	@Column(name="USER_NAME_",length=50)
	private String username;
	
	@Column(name="PWD_",length=50)
	private String password;
	
	@Column(name="LOGIN_ID_",length=100,unique=true)
	private String loginId;
	
	@Column(name = "SUPERVISOR_ID_",length=36)
	private String supervisorId;
	
	//直属上级
	@OneToOne(cascade = CascadeType.ALL)
	@JoinColumn(name = "SUPERVISOR_ID_",insertable=false,updatable=false)
	private User supervisor;
	
	@Column(name="STATE_")
	private Integer state;
	
	@ManyToMany(mappedBy="deptMember",cascade=CascadeType.ALL)
	private Set<Dept> deptList;
	
	@ManyToMany(mappedBy="userList",cascade=CascadeType.ALL)
	private Set<Duty> dutyList;
	
	public Set<Duty> getDutyList() {
		return dutyList;
	}

	public void setDutyList(Set<Duty> dutyList) {
		this.dutyList = dutyList;
	}

	public User getSupervisor() {
		return supervisor;
	}

	public void setSupervisor(User supervisor) {
		this.supervisor = supervisor;
	}

	public Set<Dept> getDeptList() {
		return deptList;
	}

	public void setDeptList(Set<Dept> deptList) {
		this.deptList = deptList;
	}


	public Integer getState() {
		return state;
	}


	public void setState(Integer state) {
		this.state = state;
	}

	public String getId() {
		return id;
	}
	
	public void setId(String id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getLoginId() {
		return loginId;
	}

	public void setLoginId(String loginId) {
		this.loginId = loginId;
	}
}
